extends Control
var LuaInit = preload("res://lua/init.gd")
var number=0
var files
func _ready():
	files = $FileManager.getFileList("res://src",true)
	#processFile("res://src/main.lua")

func update_process_label(text):
	 $Label.text=text
	
func processFile(file):
	var lua_tools = LuaInit.new()
	var filepath = file.replace("res://src","")
	var path = ProjectSettings.globalize_path(file)
	var ast = lua_tools.getFileAST(path)
	var code = lua_tools.luaASTToLua(ast,path)
	var savePath = "res://srcjs"+filepath
	savePath = savePath.get_basename() + ".js"
	$FileManager.writeContentToFile(code,ProjectSettings.globalize_path(savePath))
	number+=1
	call_deferred("update_process_label",str(number)+"/"+str(files.size()))

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if number<=(files.size()-1):
		processFile(files[number])
		pass

